//
//  EFengCommentsFrame.m
//  WZEfengAndEtong
//
//  Created by wanzhao on 16/2/29.
//  Copyright © 2016年 wanzhao. All rights reserved.
//

#import "EFengCommentsFrame.h"
#import "EFengContent.h"

@implementation EFengCommentsFrame

- (void)setCommentsArray:(NSArray *)commentsArray
{
    _commentsArray = commentsArray;
    
    __block CGSize maxSize = CGSizeMake(self.width, MAXFLOAT);
    __block CGSize contentSize;
    
    if (commentsArray.count > 0) {
        __block CGFloat heightM = 0.0f;
        [commentsArray enumerateObjectsUsingBlock:^(EFengContent *obj, NSUInteger idx, BOOL *stop) {
            contentSize = [obj.contentAttr boundingRectWithSize:maxSize options:NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading context:nil].size;
            heightM = heightM + (ceilf(contentSize.height)) + 5.0f;
        }];
        self.height = heightM;
 
    }
}

@end
